import java.time.DayOfWeek;
import java.time.LocalDate;

/**
 * Created by haiqiang on 17/10/2.
 */
public class CalendarTest {
    public static void main(String[] args) {
        LocalDate date = LocalDate.now();
        int today = date.getDayOfMonth();
        int currentMonth = date.getMonthValue();
        int dayOfYear = date.getDayOfYear();

        date = date.minusDays(dayOfYear - 1);


        for (int i = 1; i <= 12; i++) {
            System.out.println(date.getMonth());
            DayOfWeek weekday = date.getDayOfWeek();
            int value = weekday.getValue();
            System.out.println("Mon Tue Wed Thu Fri Sat Sun");
            for (int k = 1; k < value; k++) {
                System.out.print("    ");
            }
            int month = date.getMonthValue();
            while (date.getMonthValue() == month) {
                System.out.printf("%3d", date.getDayOfMonth());
                if (date.getDayOfMonth() == today && currentMonth == month) {
                    System.out.print("*");
                } else {
                    System.out.print(" ");
                }
                date = date.plusDays(1);
                if (date.getDayOfWeek().getValue() == 1)
                    System.out.println("\n");
            }
            if (date.getDayOfWeek().getValue() != 1)
                System.out.println("\n");
        }
    }
}
